#import <Ice/Ice.h>
#import "coordinationMiddleware.h"

@implementation CoordinationMiddleware

@synthesize eventHandler;

-(id) init
{
	if (![super init])
		return nil;
	
	@try{
		comm = [[ICEUtil createCommunicator] retain];
		eventHandler = [[EventHandler alloc] initWithCommunicator:comm andHost:@"localhost"];
	}
	@catch(ICEException* e)
	{
		NSLog(@"%@",e);
		return nil;
	}
	
	return self;
}

-(id) initWithHost:(NSString*)host
{
	if (![super init])
		return nil;
	
	@try{
		comm = [[ICEUtil createCommunicator] retain];
		eventHandler = [[EventHandler alloc] initWithCommunicator:comm andHost:host];
	}
	@catch(ICEException* e)
	{
		NSLog(@"%@",e);
		return nil;
	}
	
	return self;
}

-(void) dealloc
{
	[eventHandler release];
	[comm release];
	
	[super dealloc];
}

@end
